#ifndef CPU_H_
#define CPU_H_

class CPU
{
public:
	CPU();
	virtual ~CPU();
	unsigned short readRegister(int pos);
	void setRegister(int pos,short value);
	unsigned short readMemory(int pos);
	void setMemory(int pos,short value);
	void setIR(unsigned short value);
	void setPC(unsigned short value);
	unsigned short getIR();
	unsigned short getPC();
	void setFlagNeg(bool b);
	void setFlagZero(bool b);
	void setFlagNegZero(bool b);
	void setFlagCarry(bool b);
	void setFlagOverflow(bool b);
	void setFlagTrue(bool b);
	void instructionFetch();
	void instructionDecode();
	void execute();
	void writeBack();
	bool getFlagNeg();
	bool getFlagZero();
	bool getFlagNegZero();
	bool getFlagCarry();
	bool getFlagOverflow();
	bool getFlagTrue();
	void printCPUStatus();
	void saveMemory();
	void run();
	void halt();
	void setWBRegister(unsigned short reg);
	void setWBValue(short WBvalue);
	void setshallWB(bool wb);
	void setScreenMode(bool sm);
	bool getScreenMode();
	void setStartDumpPos(int dp);
	int getStartDumpPos();
	void setDumpAmount(int da);
	int getDumpAmount();
	void setPausePrint(bool pp);
	bool getPausePrint();
	
private:
	short registers[8];
	short memory[65536];
	unsigned short IR;
	unsigned short PC;
	bool flag_neg;
	bool flag_zero;
	bool flag_negzero;
	bool flag_carry;
	bool flag_overflow;
	bool flag_true;
	bool running;
	void (*func)(void);
	unsigned short WBRegister;
	short WBValue;
	bool shallWB;
	bool screenMode;
	int startDumpPos;
	int dumpAmount;
	bool pausePrint;

};

#endif /*CPU_H_*/
